<template>
  <div class="components-container">
    <!-- 编辑 -->
    <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{title}}</h3>
      <el-button type="primary" @click="readDead">读取逝者身份证</el-button>
      <el-button type="primary" @click="readAgent">读取经办人身份证</el-button>
      <div :style="{maxHeight:maxHeight+'px'}" style="overflow:auto;">
        <fieldset class="layui-elem-field layui-field-title">
          <legend>死者信息</legend>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label text-danger">逝者类型<span class="text-danger">*</span></label>
              <div class="layui-input-inline backcolor">
                <el-select v-model="regData.REGBONETYPE">
                  <el-option v-for="item in szlx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">到馆时间</label>
              <div class="layui-input-inline backcolor">
                <el-date-picker v-date type="datetime" v-model="regDataEexend.regDataTime" format="yyyy-MM-dd HH:mm"></el-date-picker>
              </div>
            </div>
           <div class="layui-inline">
              <label class="layui-form-label">逝者性别</label>
              <div class="layui-input-inline backcolor">
                <el-select v-model="regData.REGSEX" filterable>
                  <el-option v-for="item in xblx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件类型</label>
              <div class="layui-input-inline">
                <el-select v-model="regData.REGCARDTYPE" filterable>
                  <el-option v-for="item in sfzjlx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者姓名</label>
              <div class="layui-input-inline backcolor ywbackcolor">
                <el-input v-model="regData.REGNAME"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件号码</label>
              <div class="layui-input-inline backcolor">
                <el-input v-model="regData.REGCARDNO" @change="(value) => identityNumber(value)"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">详细地址</label>
              <div class="layui-input-inline backcolor">
                <el-input class="longertext" placeholder="请输入内容" v-model="regData.REGDETAILADDRESS">
                </el-input>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">出生日期</label>
              <div class="layui-input-inline backcolor">
                <el-date-picker v-date v-model="regDataEexend.RegBirthDate" type="date" @change="(value) => birthdaydata(value)"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者年龄</label>
              <div class="layui-input-inline backcolor">
                <el-input-number v-model="regData.REGAGE" :min="0"></el-input-number>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">死亡原因<span class="text-danger">*</span></label>
              <div class="layui-input-inline backcolor">
                <el-cascader :options="cause" v-model="cauinfo" filterable>
                </el-cascader>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">死亡日期<span class="text-danger">*</span></label>
              <div class="layui-input-inline backcolor">
                <el-date-picker v-date type="date" v-model="regDataEexend.regDeathDate"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">火化日期</label>
              <div class="layui-input-inline backcolor">
                <el-date-picker v-date type="date" placeholder="选择日期时间" v-model="regDataEexend.regCremationDate"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">排队序号</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGDAYNUM" :min="0" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">民族</label>
              <div class="layui-input-inline backcolor">
                <el-select v-model="regData.REGNATION">
                  <el-option v-for="item in mz" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">户籍类别<span class="text-danger">*</span></label>
              <div class="layui-input-inline">
                <el-select v-model="regData.REGHOUSEHOLDTYPE">
                  <el-option v-for="item in hjlblx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">地址类型<span class="text-danger">*</span></label>
              <div class="layui-input-inline">
                <el-select v-model="regData.REGHOUSETYPE" @change="adresstypechange($event)">
                  <el-option v-for="item in adresstype" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">户籍地址</label>
              <div class="layui-input-inline backcolor">
                <el-cascader :options="household" v-model="ctyLists" filterable :show-all-levels="false" change-on-select>
                </el-cascader>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">统计地点<span class="text-danger">*</span></label>
              <div class="layui-input-inline backcolor ywbackcolor">
                <el-cascader :options="area" v-model="carryArea" filterable :show-all-levels="false">
                </el-cascader>
              </div>
            </div>
          </div>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>家属信息</legend>
            <div class="layui-field-box">
              <div class="layui-form-item">
                <div class="layui-inline">
                  <label class="layui-form-label">家属性别</label>
                  <div class="layui-input-inline backcolor">
                    <el-select v-model="regData.REGHANDSEX" filterable>
                      <el-option v-for="item in xblx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                      </el-option>
                    </el-select>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">证件类型</label>
                  <div class="layui-input-inline">
                    <el-select v-model="regData.REGHANDLERCARDTYPE" filterable>
                      <el-option v-for="item in sfzjlx" :key="item.CODNAME" :label="item.CODALIAS" :value="item.CODNAME">
                      </el-option>
                    </el-select>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">家属姓名<span class="text-danger">*</span></label>
                  <div class="layui-input-inline backcolor ywbackcolor">
                    <el-input v-model="regData.REGHANDLERNAME"></el-input>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">证件号码</label>
                  <div class="layui-input-inline backcolor">
                    <el-input v-model="regData.REGHANDLERCARDNO"></el-input>
                  </div>
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-inline" style="width:575px;margin-right:0px;">
                  <label class="layui-form-label">详细地址</label>
                  <div class="layui-input-inline backcolor">
                    <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入详细地址" v-model="regData.REGHANDLERHOUSEHOLD">
                    </el-input>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">联系电话<span class="text-danger">*</span></label>
                  <div class="layui-input-inline backcolor ywbackcolor">
                    <el-input v-model="regData.REGHANDLERLINK"></el-input>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label">逝者关系</label>
                  <div class="layui-input-inline backcolor">
                    <el-select v-model="regData.REGRELATION" filterable allow-create default-first-option placeholder="请选择文章标签">
                      <el-option
                        v-for="item in REGRELATIONOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-inline" style="width:575px;margin-right:0px;">
                  <label class="layui-form-label">备注</label>
                  <div class="layui-input-inline">
                    <el-input class="longertext" v-model="regData.REGREMARK"></el-input>
                  </div>
                </div>
              </div>
            </div>
          </fieldset>
        </fieldset>
      </div>
      <div class="layui-form-item btnCenter">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="submit" :loading="this.$store.state.isloading">保存</el-button>
      </div>
    </sweet-modal>
    <!-- 详情 -->
    <sweet-modal ref="dialogInfo" class="dialog" :sweetModalMaxWidth="pageWidth">
      <h3>{{title}}</h3>
      <div :style="{maxHeight:maxHeight+'px'}" style="overflow:auto;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
          <legend>死者信息</legend>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">逝者类型</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGBONETYPE2" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">到馆时间</label>
              <div class="layui-input-inline">
                <el-date-picker type="datetime" v-model="regDateTimeInfo" format="yyyy-MM-dd HH:mm" readonly></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件类型</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGCARDTYPE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者姓名</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGNAME" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者性别</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGSEXDESC" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件号码</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGCARDNO" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">详细地址</label>
              <div class="layui-input-inline">
                <el-input class="longertext" readonly v-model="regData.REGDETAILADDRESS">
                </el-input>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">出生日期</label>
              <div class="layui-input-inline">
                <el-date-picker type="date" readonly v-model="regDataEexend.RegBirthDate"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">死亡日期</label>
              <div class="layui-input-inline">
                <el-date-picker type="date" readonly v-model="regDataEexend.regDeathDate"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者年龄</label>
              <div class="layui-input-inline">
                <el-input readonly v-model="regData.REGAGE"></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">死亡原因</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGCAUSADESC" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">火化日期</label>
              <div class="layui-input-inline">
                <el-date-picker type="date" readonly v-model="regDataEexend.regCremationDate"></el-date-picker>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">排队序号</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGDAYNUM" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">民族</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGNATION" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">户籍类别</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGHOUSEHOLDTYPE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">地址类型</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGHOUSETYPE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">户籍地址</label>
              <div class="layui-input-inline">
                <el-input v-model="regData.REGHOUSEHOLDDESC" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">统计地址</label>
              <div class="layui-input-inline">
                <el-input v-model="addressInfo" readonly></el-input>
              </div>
            </div>
          </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>家属信息</legend>
          <div class="layui-field-box">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">家属姓名</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGHANDLERNAME" readonly></el-input>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">家属性别</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGHANDSEXDESC" readonly></el-input>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">证件类型</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGHANDLERCARDTYPE" readonly></el-input>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">证件号码</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGHANDLERCARDNO" readonly></el-input>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">详细地址</label>
                <div class="layui-input-inline">
                  <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 4}" readonly v-model="regData.REGHANDLERHOUSEHOLD">
                  </el-input>
                </div>
              </div>
            </div>
            <div class="layui-form-item">

              <div class="layui-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGHANDLERLINK" readonly></el-input>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">逝者关系</label>
                <div class="layui-input-inline">
                  <el-input v-model="regData.REGRELATION" readonly></el-input>
                </div>
              </div>
            </div>
          </div>
        </fieldset>
      </div>
      <div class="layui-form-item btnCenter sweet-btn">
        <el-button @click="closeDialog">取消</el-button>
      </div>
    </sweet-modal>
    <!-- <checkout-add ref="checkadd"></checkout-add> -->

    <div style="display: none;">
      <object classid="clsid:090457CB-DF21-41EB-84BB-39AAFC9E271A" id="ScanCtrl" codebase="*.cab#version=1,0,0,1" width="660" height="400">
      </object>
    </div>
    <object id="view1" type="application/x-eloamplugin" width="0" height="0" name="view" />
    <object id="thumb1" type="application/x-eloamplugin" width="0" height="0" name="thumb" />
  </div>
  </template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}

.longtext {
  width: 480px;
}

.longertext {
  width: 480px;
}

.sweet-btn {
  margin-top: 20px;
}

.layui-form-label[data-v-7e4f8d8c]{
  width: 82px;
}

.layui-form-item .layui-inline{
  margin-right: 0px;
}
</style>

<script>
import { ORDER } from "@/const/orderConst.js";
import { Load, Unload, plugin } from "@/utils/scanCtrl.js";
import apiBase from "@/api/apiBase.js";
import {
  formatDate,
  timeStringToDate,
  dateStringToDate
} from "@/utils/date.js";
import sweetModal from "@/components/sweetModal";
// import checkoutAdd from "./checkoutAdd";
import { codeValid } from "@/utils/IdentityCodeValid.js";
import scanWS from "@/utils/scanWebSocket.js";
import {
  MessageBox,
  Message
} from 'element-ui';
import { connects, InfoTextCallback} from "@/utils/OcxUtil.js";
import { textnum }  from "@/utils/OcxUtil.js";
//2.3版本的良田高拍仪读取身份证信息
import openidentitycard from "@/utils/openIdentityCard.js";
//捷宇需要用到axios
import axios from 'axios'
const accesscode=typeof getaccesscode === "function" ? getaccesscode() : 'IEHlf6ROpiOyUCMko90HUzbZ7GrpejjAMimsbQ=='   //捷宇高拍仪需要更换的code码
window.onload = function() {
  // Load();
};
window.onunload = function() {
  Unload();
};
// Vue.directives('focus',{
//   inserted: function (el) {
//        el.focus();
//     }
// });
export default {
  name: "cresimplereg",
  data() {
    return {
      datalist:null, //捷宇高拍仪接收值
      id: null,
      regids: null,
      REGNAMES: null,
      REGCARDNOS: null,//身份证号码
      REGBARNO: null,//条形码
      REGDETAILADDRESSA: null,
      olddata: null,
     
      //户籍所在地
      title: null,
      order: null,
      pageWidth: 1250,
      maxHeight: 550,
      maxHeights: 200,
      ctyLists: [],
      ctyInfo: null,
      regDateTimeInfo: null,
      commonArea: null,
      //编码类型
      // commonAddr: [],
      area: [],
      carryArea: [],
      jsdata: [],
      household: [],
      causList: [],
      codeList: [],
      cause: [],
      cauinfo: [],
      szlx: [],
      ytqx: [],
      ghqx: [],
      xblx: [],
      sfzjlx: [],
      gjlb: [],
      mz: [],
      whcdlx: [],
      hyzklx: [],
      zylx: [],
      zzmmlx: [],
      hjlblx: [],
      hjszdlx: [],
      jmlx: [],
      ctydata: null,
      adresstype: [
        {CODNAME: '国内',CODALIAS: '国内'},
        {CODNAME: '其他',CODALIAS: '其他'}
      ],
      addressInfo: null,
      regData: {
        REGCYADDRESS: null,
        REGID: null,
        REGPRPID: null,
        REGDATE: null,
        REGTIME: null,
        REGDAYNUM: null,
        REGBONETYPE: null,
        REGCAUSA: null,
        REGCAUSASON: null,
        REGNAME: null,
        REGSEX: null,
        REGAGE: null,
        REGCARDTYPE: null,
        REGCARDNO: "",
        REGBIRTHDATE: null,
        REGNATION: null,
        REGHOUSEHOLDTYPE: null,
        REGHOUSETYPE: null,
        REGHOUSEHOLD: null,
        REGDETAILADDRESS: null,
        REGDEATHDATE: null,
        REGHANDLERNAME: null,
        REGHANDSEX: null,
        REGHANDLERCARDTYPE: null,
        REGHANDLERCARDNO: "",
        REGHANDLERHOUSEHOLD: null,
        REGHANDLERLINK: null,
        REGRELATION: '',
        REGREMARK: null,
        REGBONETYPE2: null,
       
      
      
      },
     
      regDataEexend: {
        regDeathDate: null,
        regDataTime: null,
        RegBirthDate: null,
        //火花日期
        regCremationDate: null
      },
      cardInfo: [],
      REGRELATIONOptions:[
        {
          label:'亲属',
          value:'亲属',
        },
        {
          label:'朋友',
          value:'朋友',
        },
        {
          label:'其他',
          value:'其他',
        }
      ],
    };
  },
  methods: {
    //获取编码
    getCode() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Registration.QueryAllCode,
        res => {
          this.codeList = res.data.content;
          for (var i in this.codeList) {
            switch (this.codeList[i].CTPID) {
              case "逝者类型":
                this.szlx = this.codeList[i].Cods;
                this.regData.REGBONETYPE = this.szlx[0].CODNAME;
                break;
              case "性别类型":
                this.xblx = this.codeList[i].Cods;
                break;
              case "身份证件类型":
                this.sfzjlx = this.codeList[i].Cods;
                this.regData.REGCARDTYPE = this.sfzjlx[0].CODNAME;
                this.regData.REGHANDLERCARDTYPE = this.sfzjlx[0].CODNAME;
                break;
              case "国籍类别":
                this.gjlb = this.codeList[i].Cods;
                break;
              case "民族":
                this.mz = this.codeList[i].Cods;
                this.regData.REGNATION = this.mz[0].CODNAME;
                break;
              case "文化程度类型":
                this.whcdlx = this.codeList[i].Cods;
                break;
              case "婚姻状况类型":
                this.hyzklx = this.codeList[i].Cods;
                break;
              case "职业类型":
                this.zylx = this.codeList[i].Cods;
                break;
              case "政治面貌类型":
                this.zzmmlx = this.codeList[i].Cods;
                break;
              case "户籍类别类型":
                this.hjlblx = this.codeList[i].Cods;
                this.regData.REGHOUSEHOLDTYPE = this.hjlblx[1].CODNAME;
                break;
              case "户籍所在地类型":
                this.hjszdlx = this.codeList[i].Cods;
                break;
              default:
            }
          }
        }
      );
    },
    //搜索信息
    // searchmessages(){
    //   let data = {
    //     REGCARDNO: this.REGCARDNOS,
    //     BARID: this.olddatas
    //   };
    //   apiBase.DoService(
    //     data,
    //     apiBase.getApiAdress().Registration.DataPushHFByCardBar,
    //     res => {
    //       this.$refs.searchmessage.close();
    //       if(res.data.content.REGID == null){
    //           // this.open("信息匹配登记自送");
    //       }else{
    //         this.open('义乌修改',res.data.content.REGID)
    //       }
    //     }
    //   );
    // },
    //快速登记提交
    // quickregistrations(){
    //   let data = {
    //     REGBARNO: this.REGBARNO,
    //   };
    //   apiBase.DoService(
    //     data,
    //     apiBase.getApiAdress().Registration.DataPushHFByCardBar,
    //     res => {
    //       this.$refs.quickregistration.close();
    //       if(res.data.content.PRPID == null){
    //         this.$message({
    //           type: "error",
    //           message: "请检查条形码！"
    //         });
    //       }else{
    //         this.open('义乌火化登记',res.data.content.PRPID);
    //       }
    //     }
    //   );
    // },
    
    //地址类型改变，户籍地址改变（地址类型为其他时，户籍地址为空）
    adresstypechange(val){
      if(val === "其他"){
        this.ctyLists = [];
      }else if(val === "国内"){
        this.ctyLists = [this.ctydata.StaCode, this.ctydata.CtyCode, this.ctydata.CntCode];
      }
    },
    
     //出生日期改变触发
    birthdaydata(val){
      this.regData.REGBIRTHDATE = formatDate(val, "yyyyMMdd");
      let now = new Date();
      var nY = now.getFullYear();
      var nM = now.getMonth() + 1;
      var nD = now.getDate();
      if (val) {
        var dY = val.getFullYear();
        var dM = val.getMonth() + 1;
        var dD = val.getDate();
        var adjust;
        if (nM * 31 + nD >= dM * 31 + dD) {
          adjust = 0;
        } else adjust = -1;
        this.regData.REGAGE = now.getFullYear() - val.getFullYear() + adjust;
      }
    },
    //证件号码改变触发
    identityNumber(val){
       if (!codeValid(val)) {
          return;
        }
      this.regDataEexend.RegBirthDate = null;
      if (val === null || val === undefined) return;
      var strDate;
      if (this.regData.REGCARDNO.length === 15)
        strDate = "19" + this.regData.REGCARDNO.substr(6, 6);
      else if (this.regData.REGCARDNO.length === 18)
        strDate = this.regData.REGCARDNO.substr(6, 8);
      else return;
      this.regDataEexend.RegBirthDate = dateStringToDate(strDate);
      this.birthdaydata(this.regDataEexend.RegBirthDate);
    },
    //获取常用地址
    // getCommonAddr() {
    //   let data = {};
    //   apiBase.DoService(
    //     data,
    //     apiBase.getApiAdress().Code.GetCommonAddress,
    //     res => {
    //       this.commonAddr = res.data.content;
    //     }
    //   );
    // },
   
    getAddr() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Code.GetAddressMap,
        res => {
          let cardata = res.data.content;
          this.area = cardata.map(item => ({
            value: item.ADDID,
            label: item.ADDNAME,
            ADDLEVEL: item.ADDLEVEL,
            ADDTOPID: item.ADDTOPID,
            children: item.Children.map(itemStr => ({
              value: itemStr.ADDID,
              label: itemStr.ADDNAME,
              ADDLEVEL: itemStr.ADDLEVEL,
              ADDTOPID: itemStr.ADDTOPID
            }))
          }));
        }
      );
    },
    //获取死亡原因
    getCausa() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Code.GetCausa, res => {
        let caudata = res.data.content;
        this.cause = caudata.map(item => ({
          label: item.CAENAME,
          value: item.CAEID,
          children: item.Caus.map(itemCau => ({
            label: itemCau.CAUNAME,
            value: itemCau.CAUID
          }))
        }));
        if (this.cause[0] && this.cause[0].children[0])
          this.cauinfo = [this.cause[0].value, this.cause[0].children[0].value];
      });
    },
   
   
    //获取户籍所在地
    getHousehold() {
      let data = {};
      apiBase.DoService(data, apiBase.getApiAdress().Code.GetHousehold, res => {
        let cardata = res.data.content;
        this.household = cardata.map(item => ({
          label: item.StaName,
          value: item.StaCode,
          children: item.List_Cty.map(itemCty => ({
            label: itemCty.CtyName,
            value: itemCty.CtyCode,
            children: itemCty.List_Cnt.map(itemCnt => ({
              label: itemCnt.CntName,
              value: itemCnt.CntCode
            }))
          }))
        }));
      });
    },
    //根据编码获取所在地
    getHouseholdInfo(code) {
      let data = {
        CODE: code
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Registration.GetHousehold,
        res => {
          this.ctydata = res.data.content;
          this.ctyLists = [this.ctydata.StaCode, this.ctydata.CtyCode, this.ctydata.CntCode];
          if (this.ctydata)
            this.ctyInfo = this.ctydata.StaName + "/" + this.ctydata.CtyName + "/" + this.ctydata.CntName;
        }
      );
    },
    //获取预约信息
    getReserveInfo(id) {
      let data = {
        PRPID: id
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Reserve.DetailPhoneReserve,
        res => {

          let resdata = res.data.content;
          // this.regData.REGPRPID = id;
          this.regData.REGDAYNUM = resdata.PRPDAYNUM;
          this.regData.REGHANDLERNAME = resdata.PRPLINKMAN;
          this.regData.REGNAME = resdata.PRPDEADNAME;
          this.regData.REGPRPID = resdata.PRPID;
          this.regData.REGHANDLERLINK = resdata.PRPLINKPHONE;
          this.regData.REGREMARK = resdata.PRPDESCRIBE;
          this.regData.REGSEX = resdata.PRPDEADSEX;
          this.regData.REGAGE = resdata.PRPDEADAGE;
          this.regData.PRPCREMATION = resdata.PRPCREMATIONDESC;
         
          if(resdata.PRPISCODE !== ""){
            this.regData.PRPISCODE = resdata.PRPISCODE;
          }
          
         

          //获取到馆时间
          if(res.data.content.REGTIMEDESC != ""){
            this.regDataEexend.regDataTime = timeStringToDate(//火化登记中到馆时间
              res.data.content.REGTIMEDESC,
              res.data.content.REGDATEDESC
            );
          }
          
          
          //参保月数
          this.regData.REGSOCIALYEAR = resdata.PRPSOCIALYEAR;
          
          
          // this.regData.REGCARDTYPE = resdata.PRPCARNOTYPE;//逝者证件类型
          if(resdata.PRPCARNOTYPE === ''){
            this.regData.REGCARDTYPE = '内地居民身份证'
          }
          this.regData.REGCARDNO = resdata.PRPCARDNO//逝者证件号码
          this.regData.REGDETAILADDRESS = resdata.PRPDETAILADDRESS;//逝者详细地址
          this.regDataEexend.regDeathDate = dateStringToDate(//死亡时间
            resdata.PRPDEATHDATE 
          );
          this.regDataEexend.RegBirthDate = dateStringToDate(//出生时间
            resdata.PRPBIRTHDAY
          );
          this.regDataEexend.regCremationDate = dateStringToDate(//火化日期
            resdata.PRPCREMATIONDATE
          );
          this.cauinfo = [resdata.PRPCAUSA,resdata.PRPCAUSASON];//死亡原因;
          // this.regData.REGHANDLERCARDTYPE = resdata.PRPLINKCARDNOTYPE;//联系人证件类型
          if(resdata.PRPLINKCARDNOTYPE === ''){
            this.regData.REGHANDLERCARDTYPE = '内地居民身份证'
          }
          this.regData.REGHANDLERCARDNO = resdata.PRPLINKCARDNO;//联系人证件号码
          this.regData.REGHANDLERHOUSEHOLD = resdata.PRPLINKADDRESS;//联系地址
          this.regData.REGRELATION = resdata.PRPRELATION;//联系人与逝者关系

          if(resdata.LIHSTATUS === "A"){
            this.regData.LINNAME = null;
          }else{
            this.regData.LINNAME = resdata.PPRLINNAME;
          }
          // PRPCORPSEADDRESS
          this.regData.REGCYADDRESS = resdata.PRPADDID;
         
        }
      );
    },
   
    //初始化下拉框数据
    initSelectData() {
      //初始化下拉框数据
      this.getCode();
      this.getCausa();
      this.getHousehold();
      this.getAddr();
    },
    //打开页面
    open(order, id) {
      this.regids = id;
      this.order = order;
      this.maxHeight = window.innerHeight - 240;
      // this.getCommonAddr();
      //清理数据
      this.dataRepeat();
      switch (this.order) {
        case "新增":
            this.initSelectData();
            this.$refs.dialog.open();
            this.title = "数据上报新增";
            this.getHouseholdInfo(this.$store.state.orginCode);
            break;
        case "修改":
            this.initSelectData();
            this.$refs.dialog.open();
            this.dataInfo(id);
            this.title = "数据上报修改";
            break;
        case "详情":
            // this.initSelectData();
            this.$refs.dialogInfo.open();
            this.dataInfo(id);
            this.title = "数据上报详情";
            break;
        default:
      }
    },
    //提交
    submit(checkout = false) {
      switch (this.order) {
        case '新增':
          this.dataAdd(checkout);
          break;
        case '修改':
          this.dataModify(checkout);
          break;
        default:
      }
    },
    //取消按钮
    closeDialog() {
        this.$refs.dialog.close();
        this.$refs.dialogInfo.close();
        this.$refs.dialog.close();
    },
    //登记新增
    dataAdd(checkout = false) {
      this.regData.REGADDID = this.carryArea[this.carryArea.length - 1];
      let data = JSON.parse(JSON.stringify(this.regData));
     
      if (
        data.REGCARDTYPE === "内地居民身份证" &&
        data.REGBONETYPE === "有名尸"
      ) {
        if (!codeValid(data.REGCARDNO)) {
          this.$message({
            type: "error",
            message: "逝者身份证号码有误！"
          });
          return;
        }

        if (
          data.REGHANDLERCARDTYPE === "内地居民身份证" &&
          data.REGHANDLERCARDNO.length > 0
        ) {
          if (!codeValid(data.REGHANDLERCARDNO)) {
            this.$message({
              type: "error",
              message: "家属身份证号码有误！"
            });
            return;
          }
        }
      }
    
      this.$store.state.isloading = true;
      //火化登记新增
      apiBase.DoService(
        data,
        apiBase.getApiAdress().DataReport.Create,
        res => {
          this.closeDialog();//取消
          this.refreshData();
          this.$message({
            type: "success",
            message: "登记成功!"
          });
        },
        res => {
          this.refreshData();
          this.$message.error(res.data.msg);
        }
      );
    },
   
    //登记修改
    dataModify(checkout = false) {
      this.regData.REGADDID = this.carryArea[this.carryArea.length - 1];
      let data = JSON.parse(JSON.stringify(this.regData));
      data.REGID = this.regids;
     
      if (
        data.REGCARDTYPE === "内地居民身份证" &&
        data.REGBONETYPE === "有名尸"
      ) {
        if (!codeValid(data.REGCARDNO)) {
          this.$message({
            type: "error",
            message: "逝者身份证号码有误！"
          });
          return;
        }
      }
      if (
        data.REGHANDLERCARDTYPE === "内地居民身份证" &&
        data.REGHANDLERCARDNO.length > 0
      ) {
        if (!codeValid(data.REGHANDLERCARDNO)) {
          this.$message({
            type: "error",
            message: "家属身份证号码有误！"
          });
          return;
        }
      }
      // this.$store.state.isloading = true;
      //火化登记修改
      apiBase.DoService(
        data,
        apiBase.getApiAdress().DataReport.Modify,
        res => {
          this.closeDialog();//关闭页面
          this.$message({
            type: "success",
            message: "修改成功!"
          });
          this.refreshData();
        },
        res => {
            this.$message.error(res.data.msg);
        }
      );
    },
   //登记详情
    dataInfo(id) {
      let data = {
        REGID: id
      };
      apiBase.DoService (
        data,
        apiBase.getApiAdress().Registration.DetailCremationRegistration,
        res => {
          this.regData.REGBONETYPE = res.data.content.REGBONETYPE;//逝者类型 
          this.regData.REGBONETYPE2 = res.data.content.REGBONETYPEDESC;
          this.regData.REGSEX = res.data.content.REGSEX;//逝者性别
          this.regData.REGSEXDESC = res.data.content.REGSEXDESC;
          this.regData.REGCARDTYPE = res.data.content.REGCARDTYPE;//证件类型
          this.regData.REGNAME = res.data.content.REGNAME;//逝者姓名
          this.regData.REGCARDNO = res.data.content.REGCARDNO;//证件号码
          this.regData.REGDETAILADDRESS = res.data.content.REGDETAILADDRESS;//详细地址
          this.regData.REGAGE = res.data.content.REGAGE;//逝者年龄
          this.regData.REGDAYNUM = res.data.content.REGDAYNUM;//排队序号
          this.regData.REGNATION = res.data.content.REGNATION;//民族
          this.regData.REGHOUSEHOLDTYPE = res.data.content.REGHOUSEHOLDTYPE;//户籍类别
          this.regData.REGHANDSEX = res.data.content.REGHANDSEX;//家属性别
          this.regData.REGHANDSEXDESC = res.data.content.REGHANDSEXDESC;//详情中的家属性别
          this.regData.REGHANDLERCARDTYPE = res.data.content.REGHANDLERCARDTYPE;//证件类型
          this.regData.REGHANDLERNAME = res.data.content.REGHANDLERNAME;//家属姓名
          this.regData.REGHANDLERCARDNO = res.data.content.REGHANDLERCARDNO;//证件号码
          this.regData.REGHANDLERHOUSEHOLD = res.data.content.REGHANDLERHOUSEHOLD;//详细地址
          this.regData.REGHANDLERLINK = res.data.content.REGHANDLERLINK;//联系电话
          this.regData.REGRELATION = res.data.content.REGRELATION;//逝者关系
          this.regData.REGCYADDRESS = res.data.content.REGCYADDRESS;//接尸地址  常用地址
          this.regData.REGREMARK = res.data.content.REGREMARK;//备注
         
          this.regData.REGID = res.data.content.REGID;
          this.regData.REGHOUSEHOLDDESC = res.data.content.REGHOUSEHOLDDESC;//详情中的户籍地址
          var arr=this.regData.REGHOUSEHOLDDESC.split(" ");  
        
          this.regData.REGCAUSADESC = res.data.content.REGCAUSADESC;//详情中的死亡原因

          this.regData.REGCAUSA = res.data.content.REGCAUSA;
          this.regData.REGCAUSASON = res.data.content.REGCAUSASON;
          this.regData.REGHOUSEHOLD = res.data.content.REGHOUSEHOLD;//逝者户籍所在地
          if(this.regData.REGHOUSEHOLD === ""){
            this.regData.REGHOUSETYPE = '其他';
          }else{
            this.regData.REGHOUSETYPE = '国内';
          };
          this.regData.REGADDID = res.data.content.REGADDID;

          this.regDateTimeInfo = timeStringToDate(//详情中的到馆时间
            res.data.content.REGTIME,
            res.data.content.REGDATE
          );
          this.regDataEexend.regDataTime = timeStringToDate(//修改中的到馆时间
            res.data.content.REGTIME,
            res.data.content.REGDATE
          );
          this.regDataEexend.RegBirthDate = dateStringToDate(//出生日期
            res.data.content.REGBIRTHDATE 
          );
          this.regDataEexend.regDeathDate = dateStringToDate(//死亡时间
            res.data.content.REGDEATHDATE
          );
          this.regDataEexend.regCremationDate = dateStringToDate(//火化日期
            res.data.content.REGCREMATIONDATE
          );
          if (this.regDataEexend.regCremationDate == null) {
            this.regDataEexend.regCremationDate = new Date();
          }
         
          //初始化死亡原因
          this.cauinfo = [this.regData.REGCAUSA, this.regData.REGCAUSASON];
          // this.ctyLists = res.data.content.REGHOUSEHOLDDESC;
          //初始化户籍地址
          this.getHouseholdInfo(this.regData.REGHOUSEHOLD);
          let currentArea = [];
          let addrId = this.regData.REGADDID;
          let addrName = null;
          this.area.forEach(function(value, index, arr) {
            value.children.forEach(function(v, i, a) {
              if (v.value == addrId) {
                currentArea.push(v.ADDTOPID, v.value);
                addrName = value.label + " / " + v.label;
              }
            });
          });
          this.carryArea = currentArea;
          this.addressInfo = addrName;
        }
      );
      
    },
    // 未到馆的详情
    WDGdataInfo(id){
      let data = {
        REGID: id
      };
      apiBase.DoService (
        data,
        apiBase.getApiAdress().Registration.DetailCremationRegistration,
        res => {
          this.regData.REGSEX = res.data.content.PRPDEADSEX;//逝者性别
          this.regData.REGSEXDESC = res.data.content.PRPDEADSEXDESC;
          this.regData.REGNAME = res.data.content.PRPDEADNAME;//逝者姓名
          this.regData.REGDETAILADDRESS = res.data.content.PRPCORPSEADDRESS;//详细地址
          this.regData.REGAGE = res.data.content.PRPDEADAGE;//逝者年龄
          this.regData.REGHANDLERNAME = res.data.content.PRPLINKMAN;//家属姓名
          this.regData.REGHANDLERLINK = res.data.content.PRPLINKPHONE;//联系电话
          this.regData.REGREMARK = res.data.content.PRPDESCRIBE;//备注
          this.regData.REGCAUSADESC = res.data.content.PRPCAUSADESC;//详情中的死亡原因
         
        }
      );
    },
    refreshData() {
      this.$emit("refreshData");
    },
    //数据重置
    dataRepeat() {
      this.cardInfo = [];
      Object.assign(this.$data.regData, this.$options.data().regData);
      Object.assign(
        this.$data.regDataEexend,
        this.$options.data().regDataEexend
      );
     
      this.regDataEexend.regDataTime = null;
      this.regData.ICENO = null;
      this.causList = [];
      this.ctyLists = [];
      this.cauinfo = [];
      this.carryArea = [];
      this.jsdata = [];
     
    },

     //读取逝者身份证
    readDead() {
       switch(ORDER.Highmeter){
        case "10":
           if (this.cardInfo && this.cardInfo.length > 0) {
              this.regData.REGCARDTYPE = "内地居民身份证";
              this.regData.REGNAME = this.cardInfo[0];
              this.regData.REGSEX = this.sex(this.cardInfo[1]);
              this.regData.REGCARDNO = this.cardInfo[7];
              this.regData.REGDETAILADDRESS = this.cardInfo[6];
              this.regData.REGNATION = this.cardInfo[2] + "族";
              this.regDataEexend.RegBirthDate = dateStringToDate(this.cardInfo[3] + this.cardInfo[4] + this.cardInfo[5]);
              this.birthdaydata(this.regDataEexend.RegBirthDate);
            } else {
              this.$message.error("身份证读取失败，请重新放置。");
            }
            this.cardInfo = [];
          break;
        case "20":
          if(textnum.text1 != ''){
            this.regData.REGNAME = textnum.text1;
            this.regData.REGCARDTYPE = "内地居民身份证";
            this.regData.REGSEX = this.sex(textnum.text3);
            this.regData.REGCARDNO = textnum.text2;
            this.regData.REGDETAILADDRESS = textnum.text6;
            this.regData.REGNATION = textnum.text4 + "族";
            this.regDataEexend.RegBirthDate = dateStringToDate(//出生日期
              textnum.text5 
            );
            this.birthdaydata(this.regDataEexend.RegBirthDate);
          }else{
            this.$message.error("身份证读取失败，请重新放置。");
          }
          textnum.text1 = '';
          textnum.text2 = '';
          textnum.text3 = '';
          textnum.text4 = '';
          textnum.text6 = '';
          break;
                 //读取逝者身份证 （捷宇）
        case "30":
          var instance = axios.create({
              baseURL: 'http://localhost:9528/',
              headers: {
                  'Access-Code': accesscode,
              }
          })
          instance.get('/IDCard').then((response)=> {
              // Do something here
              if(response.data!='')
              {
              var showdata=response.data
              this.datalist=showdata
              }
            if(response.data.error){
                this.regData.REGAGE='';
                this.regData.REGSEX='';
                this.$message.error("身份证读取失败，请重新放置。");
              }
          
          })
          .then( ()=>{
              if(this.datalist!=''){
              this.regData.REGCARDTYPE = "内地居民身份证";
              this.regData.REGNAME=this.datalist.name;
              this.regData.REGDETAILADDRESS=this.datalist.address
                  if(this.datalist.gender!=''){
                      if(this.datalist.gender=='2'){
                      this.regData.REGSEX='B'
                      }else  if(this.datalist.gender=='1'){
                          this.regData.REGSEX='A'
                      }
                  }
                this.regDataEexend.RegBirthDate = dateStringToDate(
                          //出生日期
                          this.datalist.birthDay
                          );
                this.birthdaydata(this.regDataEexend.RegBirthDate);
                    this.regData.REGCARDNO = this.datalist.code;  //证件号
                    if(this.datalist.folk!=''){
                    var code=this.datalist.folk
                    this.regData.REGNATION=JSONZU[code]
                    }
                  }
                  
                else {
                      this.$message.error("身份证读取失败，请重新放置。");
                  }
              })
            break;
        case "40":
            dialog.get_actionType("singleReadIDCard");
            setTimeout(() => {
              if (this.cardInfo && this.cardInfo.length > 0) {
                this.regData.REGCARDTYPE = "内地居民身份证";
                this.regData.REGNAME = this.cardInfo[0];
                this.regData.REGSEX = this.sex(this.cardInfo[1]);
                this.regData.REGCARDNO = this.cardInfo[7];
                this.regData.REGDETAILADDRESS = this.cardInfo[6];
                this.regData.REGNATION = this.cardInfo[2] + "族";
                this.regDataEexend.RegBirthDate = dateStringToDate(this.cardInfo[3] + this.cardInfo[4] + this.cardInfo[5]);
                this.birthdaydata(this.regDataEexend.RegBirthDate);
              } else {
                this.$message.error("身份证读取失败，请重新放置。");
              }
              this.cardInfo = [];
            }, 1000);
            break;
      default:
    }
    },
    //读取经办人身份证
    readAgent() {
      // ORDER.Highmeter = '20';
      switch(ORDER.Highmeter){
        case "10":
          if (this.cardInfo && this.cardInfo.length > 0) {
            this.regData.REGHANDLERCARDTYPE = "内地居民身份证";
            this.regData.REGHANDLERNAME = this.cardInfo[0];
            this.regData.REGHANDSEX = this.sex(this.cardInfo[1]);
            this.regData.REGHANDLERCARDNO = this.cardInfo[7];
            this.regData.REGHANDLERHOUSEHOLD = this.cardInfo[6];
          } else {
            this.$message.error("身份证读取失败，请重新放置。");
          }
          this.cardInfo = [];
          break;
        case "20":
          if(textnum.text1 != ''){
            this.regData.REGHANDLERNAME = textnum.text1;
            this.regData.REGHANDLERCARDTYPE = "内地居民身份证";
            this.regData.REGHANDSEX = this.sex(textnum.text3);
            this.regData.REGHANDLERCARDNO = textnum.text2;
            this.regData.REGHANDLERHOUSEHOLD = textnum.text6;
          }else{
            this.$message.error("身份证读取失败，请重新放置。");
          }
          textnum.text1 = '';
          textnum.text2 = '';
          textnum.text3 = '';
          textnum.text6 = '';
          break;
             //读取经办人身份证 （捷宇）
          case "30":
            var instance = axios.create({
                baseURL: 'http://localhost:9528/',
                headers: {
                    'Access-Code': accesscode
                }
            })
            instance.get('/IDCard').then((response)=> {
                // Do something here
                if(response.data!='')
                {
                var showdata=response.data
                this.datalist=showdata
                }
              if(response.data.error){
                   this.regData.REGHANDSEX='';
                  this.$message.error("身份证读取失败，请重新放置。");
                }
            
            })
            .then( ()=>{
                if(this.datalist!=''){
                this.regData.REGHANDLERCARDTYPE = "内地居民身份证";
                this.regData.REGHANDLERNAME=this.datalist.name;
                this.regData.REGHANDLERHOUSEHOLD=this.datalist.address
                    if(this.datalist.gender!=''){
                        if(this.datalist.gender=='2'){
                        this.regData.REGHANDSEX='B'
                        }else  if(this.datalist.gender=='1'){
                            this.regData.REGHANDSEX='A'
                        }
                    }
                     this.regData.REGHANDLERCARDNO = this.datalist.code;  //证件号
                    }
                   
                 else {
                        this.$message.error("身份证读取失败，请重新放置。");
                    }
                })
                    break;
        case "40":
          dialog.get_actionType("singleReadIDCard");
          setTimeout(() => {
            if (this.cardInfo && this.cardInfo.length > 0) {
              this.regData.REGHANDLERCARDTYPE = "内地居民身份证";
              this.regData.REGHANDLERNAME = this.cardInfo[0];
              this.regData.REGHANDSEX = this.sex(this.cardInfo[1]);
              this.regData.REGHANDLERCARDNO = this.cardInfo[7];
              this.regData.REGHANDLERHOUSEHOLD = this.cardInfo[6];
            } else {
              this.$message.error("身份证读取失败，请重新放置。");
            }
            this.cardInfo = [];
          }, 1000);
          break;       
        default:
      }
      
    },
    sex(sex) {
      var result;
      if (sex) {
        switch (sex) {
          case "男":
            result = "A";
            break;
          case "女":
            result = "B";
            break;
          default:
            result = "C";
            break;
        }
      } else {
        result = "D";
      }
      return result;
    },
    
  },
  components: {
    sweetModal
  },
  computed: {
    testval: {
      get: function() {
        if (
          this.regData.REGCARDNO === null ||
          this.regData.REGCARDNO === undefined
        )
          return null;
      },
      set: function(val) {
      }
    }
   
  },
  mounted() {//在模板渲染成html后调用，通常是初始化页面完成后，再对html的dom节点进行一些需要的操作。
    Load(); //id设备索引
     //是否把input的背景颜色改变
    let data = {};  
    apiBase.DoService(
      data,
      apiBase.getApiAdress().Param.GetBackgroundColor,
      res => {
        let backcolor = '';
        if(res.data.content === '20'){
          const inputs = document.querySelectorAll('.backcolor input.el-input__inner');
          backcolor = 'rgb(255,255,153)'
          for(var i = 0; i< inputs.length; i++){
          inputs[i].style.backgroundColor = backcolor
          }
        } else if (res.data.content === '30') {
          const inputs = document.querySelectorAll('.ywbackcolor input.el-input__inner');
          backcolor = 'rgb(255,255,153)'
          for(var i = 0; i< inputs.length; i++){
          inputs[i].style.backgroundColor = backcolor
          }
          // inputs[14].style.backgroundColor = '#FFF'
          // inputs[21].style.backgroundColor = '#FFF'
        }
      }
    );
  },
  created() {//在模板渲染成html前调用，即通常初始化某些属性值，然后再渲染成视图。
   let data = {};
    apiBase.DoService(
      data,
      apiBase.getApiAdress().Param.GetHighmeter,
      res => {
        ORDER.Highmeter = res.data.content;
        setTimeout(() => {
          if(ORDER.Highmeter == 10){
              scanWS.connect(message => {
              //身份证读取回调
              this.cardInfo = message.split(" ");
              if (this.cardInfo && this.cardInfo.length > 0) {
                this.$message.success("身份证读取成功。");
              } else {
                this.$message.error("身份证读取失败，请重新放置。");
              }
            });

          }else if(ORDER.Highmeter == 40){
              openidentitycard.connects(message => {
                  //身份证读取回调
                  this.cardInfo = message.split(" ");
                  if (message.indexOf("idFaceInfo:") >= 0) {
                      //判断大于1是为了区分拍照的回调数据
                      this.$message.success("身份证读取成功。");
                  }else {
                    this.$message.error("身份证读取失败，请重新放置。");
                  }
              });
          }
        }, 1000);
    });
  },
 
  watch: {
    "regDataEexend.regDeathDate": function(val) {
      this.regData.REGDEATHDATE = formatDate(val, "yyyyMMdd");
    },
    "regData.REGSOCIALYEAR": function(val) {
      const inputs = document.querySelectorAll('.backcolorred input.el-input__inner');
      if(inputs.length != 0){
        if(val < 0){
          inputs[0].style.backgroundColor = 'red';
        }else{
          inputs[0].style.backgroundColor = 'white';
        }
      }
    },
    "regDataEexend.regDataTime": function(val) {
      this.regData.REGDATE = formatDate(val, "yyyyMMdd");
      this.regData.REGTIME = formatDate(val, "hhmmss");
    },
    "regDataEexend.regCremationDate": function(val) {
      this.regData.REGCREMATIONDATE = formatDate(val, "yyyyMMdd");
    },
  
    cauinfo: function(val) {
      this.regData.REGCAUSA = val[0];
      this.regData.REGCAUSASON = val[1];
    },
    ctyLists: function(val) {
      if(val.length === 0){
        this.regData.REGHOUSEHOLD = '';
      }else{
        this.regData.REGHOUSEHOLD = val[2];
      }
    }
  }
 
};
</script>
